/*
 * Created on 29/06/2006
 *
 */
package ar.com.cubika.trainees.view;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ar.com.cubika.trainees.bean.transportes.Empresa;
import ar.com.cubika.trainees.bean.transportes.Ruta;

public class CrearRutaServlet extends TransportesServlet {
    
    

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // manejo de defaults
        Collection errores = (Collection)request.getAttribute("mensajesDeError"); 
        if (errores != null && !errores.isEmpty()) {
            request.setAttribute("origen", request.getParameter("origen"));
            request.setAttribute("destino", request.getParameter("destino"));
            request.setAttribute("kmBuenos", request.getParameter("kmBuenos"));
            request.setAttribute("kmMalos", request.getParameter("kmMalos"));
            request.setAttribute("zona", request.getParameter("zona"));
            request.setAttribute("conPeajes", 
                    request.getParameterMap().containsKey("conPeajes"));
            request.setAttribute("tipo", request.getParameter("tipo"));
        } else {
            request.setAttribute("destino", "Tucuman");
        }
        
        // para que pase el chequeo de doble submit
        this.setOperacionPermitida("agregar una ruta", request, response);
        
        // y vamos a la JSP
        request.getRequestDispatcher("/agregarRutaEnTable.jsp").forward(
                request, response);
    }

}
